package cn.edu.suse.epilepsy.controller;

import cn.edu.suse.epilepsy.entity.pojo.CaseStd;
import cn.edu.suse.epilepsy.service.CaseStdService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/caseStd")
public class CaseStdController {

    @Autowired
    private CaseStdService caseStdService;

    @PostMapping
    public boolean save(@RequestBody CaseStd caseStd) {
        return caseStdService.save(caseStd);
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id) {
        return caseStdService.removeById(id);
    }

    @PutMapping("/{id}")
    public boolean update(@RequestBody CaseStd caseStd) {
        return caseStdService.updateById(caseStd);
    }

    @GetMapping("/{id}")
    public CaseStd findById(@PathVariable Integer id) {
        return caseStdService.getById(id);
    }

    @GetMapping
    public List<CaseStd> findAll() {
        return caseStdService.list();
    }

    @GetMapping("/page")
    public IPage<CaseStd> getCaseStds(@RequestParam(defaultValue = "1") int page,
                                      @RequestParam(defaultValue = "7") int pageSize,
                                      CaseStd caseStd) {
        Page<CaseStd> pageRequest = new Page<>(page, pageSize);
        return caseStdService.getCaseStds(pageRequest, caseStd);
    }



   


}
